package com.meetingshow.meeting.dao;

import java.util.List;

import com.meetingshow.common.base.dao.BaseDAO;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.meeting.dao.model.TopicPO;

public class TopicDAO extends BaseDAO {
    public Integer saveTopic(TopicPO topicPO) throws Exception {
        return (Integer) this.saveBaseObj(topicPO);
    }

    public void updateTopic(TopicPO topicPO) throws Exception {
        this.updateBaseObj(topicPO);
    }

    public void removeTopic(TopicPO topicPO) throws Exception {
        this.deleteBaseObj(topicPO);
    }
    
    public TopicPO loadTopicById(Integer topicId) throws Exception {
        return this.queryById(TopicPO.class, topicId);
    }

    public QueryResults<TopicPO> queryTopic(QueryStruct queryStruct) throws Exception {
        QueryResults<TopicPO> queryResults = new QueryResults<TopicPO>();
        List<TopicPO> resultList = findByParameter(queryStruct);
        queryResults.setResultList(resultList);
        if (queryStruct.getFirstResultNo() != null
                && queryStruct.getResultsPerGroup() != null) {
            queryResults = queryPageInfo(queryStruct, queryResults);
        } else {
            queryResults.setTotalResultsNum(Long.valueOf(resultList.size()));
        }
        return queryResults;
    }
}
